﻿using System.Windows.Input;
using System.Windows.Media;
using Red.Controls.Diagrams.Declarators;

namespace Red.Controls.Diagrams.ViewModels
{
    public class DummyNodeViewModel : NodeViewModel
    {
        #region Properties

        public override double X
        {
            get { return 0; }
            set { }
        }

        public override double Y
        {
            get { return 0; }
            set { }
        }

        public override string Comment
        {
            get { return "Test comment"; }
            set { }
        }

        public new string Name
        {
            get { return _nodeDeclarator.Title; }
            set
            {
                _nodeDeclarator.Title = value;
                OnPropertyChanged();
            }
        }

        public new string Class
        {
            get { return _nodeDeclarator.Class; }
            set
            {
                _nodeDeclarator.Class = value;
                OnPropertyChanged();
            }
        }

        public NodeDeclarator BaseClass
        {
            get { return _nodeDeclarator.Base; }
            set
            {
                if ( value != null )
                {
                    _nodeDeclarator.BaseClass = value.Class;
                    _nodeDeclarator.Base = value;
                    InitFromNodeDeclarator( _nodeDeclarator );
                }
                OnPropertyChanged();
            }
        }

        public new bool IsContainer
        {
            get { return _nodeDeclarator.IsContainer; }
            set
            {
                if ( _nodeDeclarator.IsContainer != value )
                {
                    _nodeDeclarator.IsContainer = value;
                    CommandManager.InvalidateRequerySuggested();
                    OnPropertyChanged();
                }
            }
        }

        public new NodeVisualType VisualType
        {
            get { return _nodeDeclarator.VisualType; }
            set
            {
                _nodeDeclarator.VisualType = value;
                OnPropertyChanged();         
            }
        }

        public new Color Background
        {
            get 
            { 
                return _nodeDeclarator.Color; 
            }
            set
            {
                _nodeDeclarator.Color = value;
                OnPropertyChanged();                
            }
        }

        public bool IsAbstract
        {
            get
            {
                return _nodeDeclarator.IsAbstract;
            }
            set
            {
                _nodeDeclarator.IsAbstract = value;
                OnPropertyChanged();
            }
        }

        public NodeDeclarator Declarator => _nodeDeclarator;

        #endregion Properties

        #region C-tor

        public DummyNodeViewModel( NodeDeclarators declarators, NodeDeclarator declarator ) : base( null, declarators )
        {
            _nodeDeclarator = declarator;
        }

        #endregion C-tor

        protected override ConnectorViewModel CreateInputConnectorViewModel( NodeConnectorDeclarator connectorDeclarator, bool isInherited = false )
        {
            return new DummyConnectorViewModel( connectorDeclarator, isInherited );
        }

        protected override ConnectorViewModel CreateOutputConnectorViewModel( NodeConnectorDeclarator connectorDeclarator, bool isInherited = false )
        {
            return new DummyConnectorViewModel( connectorDeclarator, isInherited );
        }
    }
}
